<extend name="Public/base"/>
<block name="content">
  <div class="admin-content">
    <div class="admin-content-body">
      <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">{$title}</strong>  <small></small></div>
      </div>

      <hr/>

      <div class="am-g">
        <div class="am-u-sm-12 am-u-md-8 am-u-md-push-1">
          <form class="am-form am-form-horizontal" action="{:U('add_edit_lunbo')}" method="post" enctype="multipart/form-data">
            <input type="hidden" name="id" value="{$data['id']}">
            <div class="am-form-group">
              <label for="user-name" class="am-u-sm-3 am-form-label">跳转url</label>
              <div class="am-u-sm-9">
                <input type="text" id="user-name" placeholder="" name="url" value="{$data.url}">
              </div>
            </div>
            <div class="am-form-group am-form-file">
                            <label for="doc-ipt-pwd-1" class="am-u-sm-3 am-form-label">上传图片</label>
                            <div class="am-u-sm-9">
               <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                <i class="am-icon-cloud-upload"></i> 选择要上传的文件</button>
                            <input id="doc-form-file" name="logo" type="file">
                            <div id="file-list"></div>
             </div>
                    
                        </div>
            <div class="am-form-group">
              <label for="user-email" class="am-u-sm-3 am-form-label">排序</label>
              <div class="am-u-sm-9">
                <input type="text" id="user-email" name="sort" required placeholder="" value="{$data.sort}">
              </div>
            </div>
          
  
           <!--  <div class="am-form-group">
              <label for="user-QQ" class="am-u-sm-3 am-form-label">是否可见</label>
             <div class="am-u-sm-9">
               <label class="am-radio-inline">
                 <input type="radio" name="is_show" value="1" checked data-am-ucheck> 是
               </label>
               <label class="am-radio-inline">
                 <input type="radio" name="is_show" value="2" data-am-ucheck> 否
               </label>
             </div>
            </div>
 -->
            <div class="am-form-group">
              <div class="am-u-sm-9 am-u-sm-push-3">
                <button type="submit" class="am-btn am-btn-primary">保存修改</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</block>
<block name="js">
  <script>
    $(function () {
       $('#doc-form-file').on('change', function() {
      var fileNames = '';
      $.each(this.files, function() {
        fileNames += '<span class="am-badge">' + this.name + '</span> ';
      });
      $('#file-list').html(fileNames);
    });
        var form = $('form');

        $('form').submit(function (e) {
         
            e.preventDefault();
            var formData = new FormData($( "form" )[0]);
            var url = form.attr('action');
            $.ajax({
                url: url,
                type: 'POST',
                data: formData,
                dataType:'json',
                async: false,
                cache: false,
                contentType: false,
                processData: false,
                success: function (data) {
                    layer.msg(data.msg,{time:1000},function () {
                    if(data.code){
                        return false;
                    }else{
                        window.location.href=data.data;
                    }
                })
                },
                error: function (returndata) {
                    alert(returndata);
                }
            });
        })
    })
  </script>
</block>